import com.github.wxpay.sdk.WXPay;
import com.github.wxpay.sdk.WXPayUtil;
import lombok.extern.slf4j.Slf4j;
import org.elec.mac.entity.SNotifyOrder;
import org.elec.mac.wxpay.WXPayConfigImpl;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Value;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
/**
 * Created by bingren on 2018/5/19.
 */
public class Refund {

    public static void main(String[] args) {
        String appid = "wx504155708ca000ac";

        String key = "asgtqwu28snay79smai8ym0761gamj78";

        String mchid = "1492198372";

        String certpath = "D:/idea/cert1/apiclient_cert.p12";

        String notify_url = "http://bbstake.vicp.io/pay/refund.do";

        try {
            WXPayConfigImpl config = WXPayConfigImpl.getInstance(appid, mchid, key, certpath);
            WXPay wxPay = new WXPay(config);
            Map<String, String> param = new HashMap<>();
            param.put("appid",appid);
            param.put("mch_id",mchid);
            param.put("nonce_str", WXPayUtil.generateNonceStr());
            param.put("transaction_id","4200000113201807057624046683");
            param.put("out_refund_no","2018070514144510561213");
            param.put("total_fee","1");
            param.put("refund_fee","1");
            param.put("notify_url",notify_url);
            param.put("sign",WXPayUtil.generateSignature(param,key));
            log.info("退款参数：" + param);
            Map<String, String> result = wxPay.refund(param);
            log.info(""+result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
